﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Web.Services;
using System.ServiceModel;
using eBayInterface.com.ebay.developer;

namespace eBayInterface
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
    //example:
    //http://developer.ebay.com/DevZone/XML/docs/HowTo/FirstCall/MakingCallCSharp.html
            string endpoint = "https://api.ebay.com/wsapi";
            string callName = "GeteBayOfficialTime";
            string siteId = "0";
            string appId = "BIGInter-6497-4934-862a-0edb36511b90"; // use your app ID 
            string devId = "aa493a58-84f2-4d76-9b44-0c4f30658540"; // use your dev ID 
            string certId = "61066c80-dfd3-4ed5-a0a5-35da99cc1127"; // use your cert ID 
            string version = "405";
            // Build the request URL 
            string requestURL = endpoint
            + "?callname=" + callName
            + "&siteid=" + siteId
            + "&appid=" + appId
            + "&version=" + version
            + "&routing=default";
            // Create the service 
            eBayAPIInterfaceService service = new eBayAPIInterfaceService();
            // Assign the request URL to the service locator. 
            service.Url = requestURL;
            // Set credentials 
            service.RequesterCredentials = new CustomSecurityHeaderType();
            service.RequesterCredentials.eBayAuthToken = "AgAAAA**AQAAAA**aAAAAA**1paqSQ**nY+sHZ2PrBmdj6wVnY+sEZ2PrA2dj6wAkYenDpOEqAidj6x9nY+seQ**JpkAAA**AAMAAA**nvhuxkEG6ycpK3ohDndUupRYXwinPYXl9L8B0/Z8o5CLfBVSYu/j2Ysj0q3f0+IxF7W1WNhTnF4SQKXnOuU+a91ss3k5wLPWD8MKeKpd5DDqCQ97fIm0Ow7gYX6Wd4zRnPF+nEKfkShXMrxGKHBGKIKGkQUN33PpVHzze8i1VwDHICPTop7rEPYoehOh9fZVEyj+4ikBIu12WjnybkRwVfR6wCKNenm6ZcxXah8eAZ02LPsAUAKyG4SuNgNoPaNepxvig+8zf7iaeA2c/kTf7yb3fmsQtxpxtR4snV15WqYyP8zRp8N/ISuyHxZO7FPkbw3YoE1GDA+rMDwJOnIiJr9fVFSW3sEnd6v8A7g9mlgC3/W1jmLVHr9Cb8BCUOn1IY5LddBHYVbkHuJ3lhnK4X6oDuvvhct8e2NspvLa6WZB1FUXnbaaIhvyiN1sQkf+vMtxG0NW1jxYnhRmoUXCO+/IzqurWfpTZHx5BMh1JrnabCnFE9lJSoNqjp0RFTjRSlSJ28wAwv45Gqgv6C7ep1zarEv+2mrU8y+n2tT1DJ5DN8lcd1un59VP0mi/gu9cc6pEnpveb/LOydO3v5Vmy6nL78IsL7QBNES+sR2XHKQ9GNT+xPk987nSvBd1oTb02V24tPgy/4EqEFhe47whmzpV8gWKIKuBvCh3ZSEKQGCGxtma5o5dlGyBNYkwLqdokh4MJ7W5Yet20Eu/Lqe6/+zom4yMgj4QEpvo8RlTKayKYWhd7DLG2q2LzLJLDMGD";    // use your token 
            service.RequesterCredentials.Credentials = new UserIdPasswordType();
            service.RequesterCredentials.Credentials.AppId = appId;
            service.RequesterCredentials.Credentials.DevId = devId;
            service.RequesterCredentials.Credentials.AuthCert = certId;
            // Make the call to GeteBayOfficialTime 
            GeteBayOfficialTimeRequestType request = new GeteBayOfficialTimeRequestType();
            request.Version = version;
            GeteBayOfficialTimeResponseType response = service.GeteBayOfficialTime(request);
            textBox1.Text = "The time at eBay:";
            textBox2.Text = string.Format("{0}", response.Timestamp);
            textBox3.Text = string.Format("{0}", response.Ack);
            textBox4.Text = string.Format("{0}", response.CorrelationID);
            textBox5.Text = string.Format("{0}", response.Version);
            textBox6.Text = string.Format("{0}", response.Build);

        }
    }
}
